import { VuexModule, Module, Action, Mutation, getModule } from 'vuex-module-decorators'

import store from '@/store'
interface UserInfo {
    id: string
    name: string
}
export interface UserModulesState {
    userInfo: UserInfo | null
}

@Module({ namespaced: true, dynamic: true, store, name: 'user' })
class User extends VuexModule implements UserModulesState {
    userInfo: UserInfo | null = null
    menuChange=false
    @Mutation
    setMenuChange(type:boolean) {
        this.menuChange = type
    }
    @Mutation
    setUserInfo(info: UserInfo | null) {
        this.userInfo = info
    }
    @Action
    public async getUserInfo() {
        if (this.userInfo && this.userInfo.id) {
            //
        } else {
            // const response = await getUserInfo()
            // this.setUserInfo(response)
        }

    }
}

export const UserModule = getModule(User, store)
